<?php


namespace app\common\config\logic;


use app\common\config\model\ConfigSource;

class SourceLogic
{
    public function getSource($id)
    {
        $logic = new DictionaryLogic();
        return $logic->getItem($id, ConfigSource::class);
    }

    public function getChildren($id) {
        $source = $this->getSource($id);
        $path = $source['path'];
        $model = new ConfigSource();

        return $model->whereLike('path', $path."%")->column('id');
    }

    /**
     * 获取异业合作的渠道
     */
    public function getCooperation()
    {
        $model = new ConfigSource();
        $where = [
            'parent_id' => 6,
        ];
        return $model->where($where)->column('id');
    }
}